package com.example.demo.servise.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.dao.bookdao;
import com.example.demo.domain.consignee;
import com.example.demo.servise.ibookServers;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ibookserverimpl extends ServiceImpl<bookdao, consignee> implements ibookServers {
  @Autowired
  private bookdao bkd;

    @Override
    public IPage<consignee> getPage(int currentPage, int pageSize) {
        IPage page=new Page(currentPage,pageSize);
        bkd.selectPage(page,null);
        return page;
    }

    @Override
    public IPage<consignee> getPage(int currentPage, int pageSize, consignee con) {
        LambdaQueryWrapper<consignee> lqw =new LambdaQueryWrapper<consignee>();
        lqw.like(con.getId()!=null,consignee::getId,con.getId());
        lqw.like(Strings.isNotEmpty(con.getCgnName()),consignee::getCgnName,con.getCgnName());
        lqw.like(con.getUserId() !=null,consignee::getUserId,con.getUserId());
        IPage page=new Page(currentPage,pageSize);
        bkd.selectPage(page,lqw);
        return page;
    }

//    public Object getPage(int currentPage, int pageSize, consignee con) {
//    }
}
